/**
 * 玩家信息显示
 */
cc.Class({
    extends: cc.Component,

    properties: {
        headSprite: cc.Sprite,
        nameLabel: cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    // update (dt) {},

    initView(nickname, imgUrl){
        //头像
        var avatarUrl = imgUrl + "?aaa=aa.jpg";
        this.createImage(this.headSprite, avatarUrl);
        //昵称
        this.nameLabel.string = nickname;
    },

    createImage(sprite, url){
        let image = wx.createImage();
        image.onload = function () {
        let texture = new cc.Texture2D();
        texture.initWithElement(image);
        texture.handleLoadedTexture();
        sprite.spriteFrame = new cc.SpriteFrame(texture);
        sprite.node.width = 150;
        sprite.node.height = 150;
        };
        image.src = url;
    },
});
